package main

import "fmt"

func main() {
	var scores01 map[string]int = map[string]int{"english": 88, "chinese": 85}
	scores02 := map[string]int{"english": 80, "chinese": 85}
	scores03 := make(map[string]int)
	scores03["english"] = 80
	scores03["chinese"] = 85
	fmt.Println(scores01, scores02, scores03)

	var scores04 map[string]int
	if scores04 == nil {
		scores04 = make(map[string]int)
	}
	scores04["chinese"] = 90
	fmt.Println(scores04)

	scores04["math"] = 95
	scores04["math"] = 100
	fmt.Println(scores04["math"])
	delete(scores04, "math")
	fmt.Println(scores04["math"])

	scores05 := map[string]int{"english": 80, "chinese": 85}
	math, ok := scores05["math"]
	if ok {
		fmt.Printf("math的值是: %d\n", math)
	} else {
		fmt.Println("math不存在")
	}

	scores06 := map[string]int{"english": 80, "chinese": 85}
	if math, ok := scores06["math"]; ok {
		fmt.Printf("math的值是: %d\n", math)
	} else {
		fmt.Println("math不存在")
	}

	scores07 := map[string]int{"english": 80, "chinese": 85}
	for subject, score := range scores07 {
		fmt.Printf("key: %s, value: %d\n", subject, score)
	}

	scores08 := map[string]int{"english": 80, "chinese": 85}
	for subject := range scores08 {
		fmt.Printf("key: %s, value: %d\n", subject, scores08[subject])
	}

	scores09 := map[string]int{"english": 80, "chinese": 85}
	for _, score := range scores09 {
		fmt.Printf("value: %d\n", score)
	}

	male := true
	fmt.Println(!male == false)
	fmt.Println(male != false)

	age := 15
	gender := "male"
	fmt.Println(age > 18 && gender == "male")
	fmt.Println(age < 18 || gender == "male")
}

func bool2int(b bool) int {
	if b {
		return 1
	}
	return 0
}

func int2bool(i int) bool {
	return i != 0
}
